package com.feng.springboot.controller.test;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class RestController {

    @RequestMapping("/restfull")
    public String restFull(){
        return "restfull";
    }

    @GetMapping("/getMethod")
    public String getMethod(){
        return "success";
    }

    @PostMapping("/postMethod")
    public String postMethod(Model model,String name){
        model.addAttribute("name",name);
        return "success";
    }

    @PutMapping("/putMethod")
    public String putMethod(Model model,String name){
        model.addAttribute("name",name);
        return "success";
    }

    /**
     *  2021-11-10 16:38:01.404  WARN 11024 --- [nio-8088-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver :
     *  Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'DELETE' not
     *  supported]
     * @param model
     * @param name
     * @return
     */
    @PutMapping("/deleteMethod")
    public String deleteMethod(Model model,String name){
        model.addAttribute("name",name);
        return "success";
    }
}
